From dbb71d75b5ea051a25040bab23715f80e1c046d2 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 31 Jan 2024 09:14:55 +0700
Subject: Fix pagination on category detail page

---
 src/pages/shop/category/[slug].jsx | 43 +++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 19 deletions(-)

(limited to 'src/pages/shop/category/[slug].jsx')

diff --git a/src/pages/shop/category/[slug].jsx b/src/pages/shop/category/[slug].jsx
index 6d3985a8..64f1e350 100644
--- a/src/pages/shop/category/[slug].jsx
+++ b/src/pages/shop/category/[slug].jsx
@@ -1,25 +1,30 @@
-import dynamic from 'next/dynamic'
-import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug'
-import { useRouter } from 'next/router'
-import _ from 'lodash'
-import Seo from '@/core/components/Seo'
-import Breadcrumb from '@/lib/category/components/Breadcrumb'
+import dynamic from 'next/dynamic';
+import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug';
+import { useRouter } from 'next/router';
+import _ from 'lodash';
+import Seo from '@/core/components/Seo';
+import Breadcrumb from '@/lib/category/components/Breadcrumb';
 
-const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout'))
-const ProductSearch = dynamic(() => import('@/lib/product/components/ProductSearch'))
+const BasicLayout = dynamic(() =>
+  import('@/core/components/layouts/BasicLayout')
+);
+const ProductSearch = dynamic(() =>
+  import('@/lib/product/components/ProductSearch')
+);
 
 export default function CategoryDetail() {
-  const router = useRouter()
-  const { slug = '' } = router.query
+  const router = useRouter();
+  const { slug = '', page = 1 } = router.query;
 
-  const categoryName = getNameFromSlug(slug)
-  const categoryId = getIdFromSlug(slug)
-  const q = router?.query.q || null
+  const categoryName = getNameFromSlug(slug);
+  const categoryId = getIdFromSlug(slug);
+  const q = router?.query.q || null;
   const query = {
-    fq: `category_id_i:${categoryId}`
-  }
+    fq: `category_id_i:${categoryId}`,
+    page,
+  };
   if (q) {
-    query.q = q
+    query.q = q;
   }
 
   return (
@@ -30,8 +35,8 @@ export default function CategoryDetail() {
         additionalMetaTags={[
           {
             property: 'keywords',
-            content: `Jual ${categoryName}, harga ${categoryName}, ${categoryName} murah, toko ${categoryName}, ${categoryName} jakarta, ${categoryName} surabaya`
-          }
+            content: `Jual ${categoryName}, harga ${categoryName}, ${categoryName} murah, toko ${categoryName}, ${categoryName} jakarta, ${categoryName} surabaya`,
+          },
         ]}
       />
 
@@ -41,5 +46,5 @@ export default function CategoryDetail() {
         <ProductSearch query={query} prefixUrl={`/shop/category/${slug}`} />
       )}
     </BasicLayout>
-  )
+  );
 }
-- 
cgit v1.2.3


From 02897ae8c1866da91f0c256ffbb46fc0cb97e0c2 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 31 Jan 2024 09:19:45 +0700
Subject: Fix import sequence

---
 src/pages/shop/category/[slug].jsx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'src/pages/shop/category/[slug].jsx')

diff --git a/src/pages/shop/category/[slug].jsx b/src/pages/shop/category/[slug].jsx
index 64f1e350..1afe30bf 100644
--- a/src/pages/shop/category/[slug].jsx
+++ b/src/pages/shop/category/[slug].jsx
@@ -1,8 +1,9 @@
+import _ from 'lodash';
 import dynamic from 'next/dynamic';
-import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug';
 import { useRouter } from 'next/router';
-import _ from 'lodash';
+
 import Seo from '@/core/components/Seo';
+import { getIdFromSlug, getNameFromSlug } from '@/core/utils/slug';
 import Breadcrumb from '@/lib/category/components/Breadcrumb';
 
 const BasicLayout = dynamic(() =>
-- 
cgit v1.2.3

